package com.orange.wwwapi.controller.coupon;

import com.orange.core.service.user.UserCouponService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping("/coupon/pay/notify")
public class CouponPayCallbackController {

    private final UserCouponService userCouponService;

    /**
     * 微信支付回调
     */
    @PostMapping("/wechat")
    public String wechatPayNotify(@RequestBody String notifyResult) {
        log.info("微信支付回调：{}", notifyResult);
        return userCouponService.wechatPayNotify(notifyResult);
    }

    /**
     * 微信退款回调
     */
    @PostMapping("/refund")
    public String wechatRefundNotify(@RequestBody String notifyResult) {
        log.info("微信退款回调：{}", notifyResult);
        return userCouponService.wechatRefundNotify(notifyResult);
    }
}
